from django.shortcuts import render, redirect

from staffhours.forms import DeviceTypeForm
from staffhours.models import DeviceType



# Create your views here.


def index_page(request):

    context = {

    }
    return render(request,'staffhours/home.html',context)


def add_devicetype(request):
    dt_form = DeviceTypeForm()

    if request.method == 'POST':
        dt_form = DeviceTypeForm(request.POST)
        if dt_form.is_valid():
            name_get = dt_form.cleaned_data['typename']

            devicetype = DeviceType.objects.create(typename=name_get)
            devicetype.save()

            return redirect('index')


    context = {
        'dt_form':dt_form,

    }
    return render(request,'staffhours/add_devicetype.html',context)